<template>
  <view class="bg">
    <view class="pbg"></view>
  </view>
</template>

<script setup>
import { onLoad } from "@dcloudio/uni-app";
import { wxLogin } from '@/api/user.js'

onLoad(() => {
  const schoolId = uni.getStorageSync('schoolId');
  const proxyId = uni.getStorageSync('proxyId');
  uni.login({
    provider: 'weixin', //使用微信登录
    success: function (loginRes) {
      wxLogin({
        code: loginRes.code,
        schoolId,
        proxyId
      }).then(res => {
        uni.setStorageSync('token', res.data.accessToken)
        uni.switchTab({
          url: '/pages/index/index',
          success: function (res) {
            uni.showToast({
              title: '登录成功',
              icon: 'success',
            })
          }
        })
      })
    }
  });
})

</script>

<style scoped>
.bg {
  height: 100vh;
  width: 100vw;
  position: relative;
}

.pbg {
  position: absolute;
  height: 480rpx;
  width: 480rpx;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
	background-image: url('https://campus-card-oss.jxwazx.cn.cn/xiaoyuanka/loading_pro.gif');
}
</style>
